﻿using System.Globalization;
namespace Renci.Data.Interop.OpenGIS.Gml
{
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.opengis.net/gml")]
    [System.Xml.Serialization.XmlRootAttribute("pos", Namespace = "http://www.opengis.net/gml", IsNullable = false)]
    public class DirectPositionType : ISRSReferenceGroup
    {
        /// <summary>
        /// Default constructor. Required for serialization.
        /// </summary>
        public DirectPositionType()
        {

        }

        /// <summary>
        /// Creates instace of the <see cref="DirectPositionType"/> with specified coordinates.
        /// </summary>
        /// <param name="x">Latitude</param>
        /// <param name="y">Longitude</param>
        public DirectPositionType(double x, double y)
            : this()
        {
            this.X = x;
            this.Y = y;
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlTextAttribute()]
        public string Text
        {
            get
            {
                return string.Format(CultureInfo.InvariantCulture, "{0} {1}", this.X, this.Y);
            }
            set
            {
                string[] xy = value.Split(new char[] { ' ' });
                this.X = double.Parse(xy[0], CultureInfo.InvariantCulture);
                this.Y = double.Parse(xy[1], CultureInfo.InvariantCulture);
            }
        }

        /// <summary>
        /// Gets or sets X coordinate
        /// </summary>
        [System.Xml.Serialization.XmlIgnore]
        public double X { get; set; }

        /// <summary>
        /// Gets or sets Y coordinate
        /// </summary>
        [System.Xml.Serialization.XmlIgnore]
        public double Y { get; set; }

        #region ISRSReferenceGroup Members

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute("srsName", DataType = "anyURI")]
        public string SrsName { get; set; }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute("srsDimension")]
        public string SrsDimension { get; set; }

        #endregion

        #region ISRSInformationGroup Members

        /// <summary>
        /// Ordered list of labels for all the axes of this CRS. The gml:axisAbbrev value should be used for these axis 
        /// labels, after spaces and forbiddden characters are removed. When the srsName attribute is included, this attribute is optional. 
        /// When the srsName attribute is omitted, this attribute shall also be omitted.
        /// </summary>
        [System.Xml.Serialization.XmlAttributeAttribute("axisLabels")]
        public string AxisLabels { get; set; }

        /// <summary>
        /// Ordered list of unit of measure (uom) labels for all the axes of this CRS. The value of the string in the 
        /// gml:catalogSymbol should be used for this uom labels, after spaces and forbiddden characters are removed. When the 
        /// axisLabels attribute is included, this attribute shall also be included. When the axisLabels attribute is omitted, this attribute 
        /// shall also be omitted.
        /// </summary>
        [System.Xml.Serialization.XmlAttributeAttribute("uomLabels")]
        public string UomLabels { get; set; }

        #endregion
    }
}
